package mysql

import "gorm.io/gorm"

type User struct {
	gorm.Model
	Account  string `gorm:"type:varchar(20);not null;comment:'账号'"`
	Password string `gorm:"type:char(32);not null;comment:'密码'"`
	Mobile   string `gorm:"type:char(11);not null;comment:'手机号'"`
}

type RealName struct {
	gorm.Model
	UserId   int    `gorm:"type:int;not null;comment:'用户id'"`
	RealName string `gorm:"type:varchar(20);not null;comment:'真实姓名'"`
	IdCard   string `gorm:"type:char(18);not null;comment:'身份证号'"`
}

func (r *RealName) RealNameList() error {
	return DB.Where("user_id", r.ID).Limit(1).Find(&r).Error
}

func (r *RealName) RealNameAdd() error {
	return DB.Create(&r).Error
}
